package com.renren.webmaven2.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.renren.eliya.domain.SmallYForSclool;
import com.renren.yx.base.dao.daoutil.InitDao;

/**
 * write
 * 
 * @author jizhong.yang
 * @version V1.0
 */

@Service
@SuppressWarnings("unchecked")
public class IndexService {

	public int getHaveYCount() {
		return InitDao.getDao().findCountEntities(
				"select count(*) From SmallYForSclool s where s.haveY=1");
	}

	public List<SmallYForSclool> getFriendHaveY(String school) {
		if ("".equals(school)) {
			return new ArrayList<SmallYForSclool>();
		}
		return InitDao.getDao().findEntities(
				"from SmallYForSclool s where s.haveY=1 and s.school= '"
						+ school + "'");
	}

	public SmallYForSclool add() {
		SmallYForSclool smallYForSclool = new SmallYForSclool();
		smallYForSclool.setFriend(2);
		smallYForSclool.setHaveY(1);
		smallYForSclool.setLoveY(1);
		smallYForSclool.setRrid(11111111);
		smallYForSclool.setSchool("1111");
		smallYForSclool.setTinyUrl("asdfasdf");
		smallYForSclool = (SmallYForSclool) InitDao.getDao().addEntity(
				smallYForSclool);
		return smallYForSclool;
	}

	public SmallYForSclool mod() {
		SmallYForSclool smallYForSclool = (SmallYForSclool) InitDao.getDao()
				.getEntity(SmallYForSclool.class, 2);
		smallYForSclool.setSchool("ffffffffff");
		InitDao.getDao().updateEntity(smallYForSclool);
		return smallYForSclool;
	}

}
